cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
PROJECT (DEMO)
SET(CMAKE_C_COMPILER g++)
SET(CMAKE_CXX_COMPILER g++)
SET(CMAKE_CXX_STANDARD 11)

SET(INC_DIR ${DEMO_SOURCE_DIR}/include)
SET(UTIL_INC_DIR ${DEMO_SOURCE_DIR}/src/util)
SET(LIBEVENT_INC_DIR /opt/libevent/include)
SET(JPEG_INC_DIR /opt/jpeg/include)

SET(LINK_DIR ${DEMO_SOURCE_DIR}/lib)
SET(LIBEVENT_LINK_DIR /opt/libevent/lib)
SET(JPEG_LINK_DIR /opt/jpeg/lib)

SET(EXECUTABLE_OUTPUT_PATH ${DEMO_SOURCE_DIR}/bin)

add_definitions(-DLINUX -D_GNU_SOURCE)

INCLUDE_DIRECTORIES(${INC_DIR} ${UTIL_INC_DIR} ${LIBEVENT_INC_DIR} ${JPEG_INC_DIR})
LINK_DIRECTORIES(${LINK_DIR} ${LIBEVENT_LINK_DIR} ${JPEG_LINK_DIR})

SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb -fpermissive -D__linux__ -D__PTHREADS__ -D__PTHREADS_MUTEXES__ -DALLOW_NON_WORD_ALIGN_ACCESS -DREENTRANT -DEXPORT")
SET(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall -fpermissive -D__linux__ -D__PTHREADS__ -D__PTHREADS_MUTEXES__ -DALLOW_NON_WORD_ALIGN_ACCESS -DREENTRANT -DEXPORT")

#IF(debug)
#    ADD_DEFINITIONS( -g -fpermissive -D__linux__ -D__PTHREADS__ -D__PTHREADS_MUTEXES__
#        -DALLOW_NON_WORD_ALIGN_ACCESS -DREENTRANT -DEXPORT)
#ELSE()
#    ADD_DEFINITIONS( -O3 -DNDEBUG -fpermissive -D__linux__ -D__PTHREADS__ -D__PTHREADS_MUTEXES__
#        -DALLOW_NON_WORD_ALIGN_ACCESS -DREENTRANT -DEXPORT)
#ENDIF()

#IF(rel)
#    ADD_DEFINITIONS( -O3 -DNDEBUG -fpermissive -D__linux__ -D__PTHREADS__ -D__PTHREADS_MUTEXES__
#        -DALLOW_NON_WORD_ALIGN_ACCESS -DREENTRANT -DEXPORT)
#ENDIF()
#INCLUDE_DIRECTORIES(${DEMO_SOURCE_DIR}/include ${DEMO_SOURCE_DIR}/src/util)
#LINK_DIRECTORIES(${DEMO_SOURCE_DIR}/lib)
#SET(INC_DIR ${DEMO_SOURCE_DIR}/include)
#SET(LINK_DIR ${DEMO_SOURCE_DIR}/lib)

#INCLUDE_DIRECTORIES(${INC_DIR})
#LINK_DIRECTORIES(${LINK_DIR})

ADD_SUBDIRECTORY(src)


